﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;

namespace visu.Controllers
{
    public class ReportController : Controller
    {
        //
        // GET: /Report/

        public ActionResult ReportListInfo()
        {
            return View();
        }

        #region=================================出库信息==================================================
        public ActionResult MaterialOut()
        {
            return View();
        }
        public ActionResult MaterialOutDetail(int page, int rows, vmaterialout vmaterialout, string SearchContains, string sort, string order)
        {
            sort = string.IsNullOrEmpty(sort) ? "PROCESS_TIME" : sort;
            order = string.IsNullOrEmpty(order) ? "desc" : order;

            SearchCondition condition = new SearchCondition() { Field = "COMPANY_ID", Operator = "=", Value = OperateContext.userInfo.COMPANY_ID.ToString() };
            List<SearchCondition> listSearch = new List<SearchCondition>();
            listSearch.Add(condition);

            Expression<Func<vmaterialout, bool>> exp = SearchExpression.GetSearchExpression<vmaterialout>(vmaterialout, listSearch, SearchContains, "M_SPECIFICATION", "M_CODE", "PRODUCT_NO", "M_TYPE");

            var list = BLLSession.Current.vmaterialoutBLL.GetPagedList(page, rows, exp, sort, order);
            int count = DALSession.Current.vmaterialoutDAL.GetCount(exp);
            LayuiDataPager dataPager = new LayuiDataPager() { code = 0, count = count, data = list, msg = "", total = count, rows = list };

            return Json(dataPager, JsonRequestBehavior.AllowGet);
        }
        #endregion

        #region=================================入库信息==================================================
        public ActionResult MaterialIn()
        {
            return View();
        }
        public ActionResult MaterialInDetail(int page, int rows, vmaterialin vmaterialin, string SearchContains, string sort, string order)
        {
            sort = string.IsNullOrEmpty(sort) ? "PROCESS_TIME" : sort;
            order = string.IsNullOrEmpty(order) ? "desc" : order;

            SearchCondition condition = new SearchCondition() { Field = "COMPANY_ID", Operator = "=", Value = OperateContext.userInfo.COMPANY_ID.ToString() };
            List<SearchCondition> listSearch = new List<SearchCondition>();
            listSearch.Add(condition);

            Expression<Func<vmaterialin, bool>> exp = SearchExpression.GetSearchExpression<vmaterialin>(vmaterialin, listSearch, SearchContains, "M_SPECIFICATION", "M_CODE", "PRODUCT_NO", "M_TYPE");

            var list = BLLSession.Current.vmaterialinBLL.GetPagedList(page, rows, exp, sort, order);
            int count = DALSession.Current.vmaterialinDAL.GetCount(exp);
            LayuiDataPager dataPager = new LayuiDataPager() { code = 0, count = count, data = list, msg = "", total = count, rows = list };

            return Json(dataPager, JsonRequestBehavior.AllowGet);
        }
        #endregion


    }
}
